package com.bio;

import java.io.*;
import java.net.Socket;


public class BioSocketClient {

    public static void main(String[] args) {
        Socket socket = null;
        OutputStream outputStream = null;
        BufferedWriter bufferedWriter = null;
        try {
            socket = new Socket("127.0.0.1", 8090);
            outputStream = socket.getOutputStream();
            bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream));
            while (true) {
                String message = null;
                try {
                    System.out.println("请输入需要发送的message:");
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
                    message = bufferedReader.readLine();
                    bufferedWriter.write(message);
                    bufferedWriter.flush();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                System.out.println("发送的消息：" + message);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                outputStream.close();
                bufferedWriter.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
